<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
        <title>CRM</title>
        <link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/aui.css}" />
        <link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/choose_saler.css}" />
        <link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_835360_8flqp9ignrc.css"/>
        <script src="../static/azxcrm/js/wap/jquery-3.3.1.min.js" type="text/javascript" th:src="@{/azxcrm/js/wap/jquery-3.3.1.min.js}"
                charset="utf-8"></script>
        <script th:inline="javascript"> var ctx = [[@{/}]]; </script>   
    </head>
    <body>
        <!--头部结构-->
        <form role="form" class="clearfix" id="form-dispatchSalesmanDetails-add">
        <div class="g-head">
            <header class="aui-bar aui-bar-nav">
                <a class="aui-pull-left aui-btn"  href="javascript:history.go(-1)">
                    <span class="iconfont icon-fanhui1"></span>返回
                </a>
                <div class="aui-title">选择销售</div>
            </header>
        </div>
        <!--头部结构-->
        <div class="g-titile">
            <section class="aui-content bigbox">
                <div class="aui-card-list clearfix" th:each="user:${users}">
                    <div class="aui-card-list-header aui-card-list-user aui-border-b clearfix">
                        <div class="aui-list-item-inner clearfix">
                            <div class="aui-list-item-input">
                                <label><input class="aui-radio" id="userId" type="radio" name="demo1" th:value="${user.userId}"></label>                       
                            </div>
                        </div>
                        <div class="aui-card-list-user-avatar">
                            <img src="../azxcrm/image/wap/tou.png" class="aui-img-round" />
                        </div>
                        <div class="aui-card-list-user-name">
                            <div th:text="${user.loginName}"></div>
                            <a class="s-detail">可选</a>
                        </div>
                        <div class="aui-card-list-user-info" th:text="${user.phonenumber}"></div>
                    </div>
                </div> 

        </section>
     </div>
        
        <!--按钮结构-->
     <footer class="aui-bar aui-bar-tab" id="footer">
        <a href="javascript:;" class="aui-bar-tab-item">                   
             <!-- <div class="aui-bar-tab-label">确认</div> -->
             <div class="btn-group">          
                <input type="hidden" id="orderId" name="orderId" th:value="${orderId}">
                <input type="button" th:value="确认" id='toastBtn' class="btn btn-warning dropdown-toggle"  onclick="return check(this.form)" >
            </div>
        </a>           
     </footer>
    </form>
    <!--按钮结构-->
    </body>
</html>
<script src="../static/ajax/libs/layer/layer.min.js" th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script>

        $(".s-detail").each(function (index) {
            if ($(this).text() == "不可选") {
                $(this).removeClass('s-detail');
                $(this).addClass('s-up-detail');
                $(".aui-radio").eq(index).attr("disabled", "disabled");
                $(".aui-radio").eq(index).attr("disabled", true).prop("checked", false); 
            }
        })
        
    

function check(form) {   
        	
    var userId = $("input[name='demo1']:checked").val();   
    var orderId = document.getElementById('orderId').value; 
   
    $.ajax({
        cache : true,
        type : "POST",
        url : ctx + "/wap/wapSelectSalesSave",
        data :{"salesUserId": userId,"orderId": orderId,},
        async : false,
        error : function(request) {
        	layer.msg("系统错误", "error");
        },
        success : function(data) {
                   if (data.code == 0) {  
                	   layer.msg("分配成功");
                	   $("#toastBtn").removeAttr("onclick");
                	    setTimeout(function(){
                            window.location.href= ctx + "indexWap"
                            },2200)
                           
                    } else {                   
                    	layer.msg("添加失败");
                 } 
          }
    });
}
</script>
